<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title>GNUcode.me</title><id>https://gnucode.me/feeds/tags/email opensmtpd.xml</id><subtitle>Tag: email opensmtpd</subtitle><updated>2023-05-12T11:47:31Z</updated><link href="gnucode.me/feeds/tags/email opensmtpd.xml" rel="self" /><link href="gnucode.me" /><entry><title>Hosting your Own Email Part 2</title><id>https://gnucode.me/hosting-your-own-email-part-2.html</id><author><name>Joshua Branson</name><email>jbranso@dismail.de</email></author><updated>2021-06-15T03:46:00Z</updated><link href="https://gnucode.me/hosting-your-own-email-part-2.html" rel="alternate" /><summary type="html">&lt;h1&gt;PROJECT My current plans for hosting email accounts&lt;/h1&gt;&lt;h2&gt;There are three basic vocab to know for setting up an email server&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;a mail transfer agent (MTA) receives and sends email (opensmtpd)&lt;/li&gt;&lt;li&gt;a mail delivery agent (MDA), which gets the email from the MTA,
and stores it for a user.  The easiest way is to use opensmtpd as
the MDA.  BUT dovecot is a better MDA, because dovecot can set up
mail filtering and maybe better spam filtering.&lt;/li&gt;&lt;li&gt;Remote users can access the emails via an MUA (mail user agent),
via an IMAP server. (dovecot)&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;My current &lt;em&gt;simple&lt;/em&gt; strategy for hosting a few email accounts&lt;/h2&gt;&lt;p&gt;I plan on offering paid email accounts on gnucode.me, or your own domain.
So your next email could be &amp;quot;YourName@gnucode.me&amp;quot; or
&amp;quot;wilycatperson@YourDomain.com&amp;quot;.  The following is an explanation of how it
will all work together.  It is intended for anyone else wanting to set up
an email server for a &lt;em&gt;few email accounts.&lt;/em&gt;&lt;/p&gt;&lt;p&gt;Opensmtpd is my MTA (mail transfer agent), so it sends and receives email
via smtp. Also, opensmtpd uses rspamd (or bogofilter) to limit spam.&lt;/p&gt;&lt;p&gt;Dovecot will serve my emails. For now I will set up emails in the maildir
format, because this is easy to do. Eventually, I will store email in the
&lt;a href=&quot;https://doc.dovecot.org/admin_manual/mailbox_formats/dbox/&quot;&gt;dbox format.&lt;/a&gt;&lt;/p&gt;&lt;ul&gt;&lt;li&gt;&lt;code&gt;imap.gnucode.me&lt;/code&gt; will be where dovecot serves emails&lt;/li&gt;&lt;li&gt;&lt;code&gt;smtp.gnucode.me&lt;/code&gt; will be where opensmtp sends and receives email&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;The &lt;em&gt;simple&lt;/em&gt; directory structure I will use to host &lt;em&gt;a few&lt;/em&gt; email accounts&lt;/h3&gt;&lt;p&gt;I will have a few email accounts at gnucode.me &lt;code&gt;&amp;lt;users&amp;gt;@gnucode.me&lt;/code&gt;.
postmaster AT gnucode.me will point to my main user AT gnucode.me.&lt;/p&gt;&lt;p&gt;My email will be hosted at: &lt;code&gt;/home/&amp;lt;user&amp;gt;/Maildir&lt;/code&gt;&lt;/p&gt;&lt;p&gt;I will tell dovecot to serve emails from the above
&lt;a href=&quot;https://doc.dovecot.org/settings/core/?highlight=mail_location#setting-mail-location&quot;&gt;directory&lt;/a&gt;
via a &lt;a href=&quot;https://doc.dovecot.org/configuration_manual/config_file/config_variables/#variables-mail-user&quot;&gt;config
variable:&lt;/a&gt;&lt;/p&gt;&lt;pre&gt;&lt;code&gt;(dovecot-service #:config
                     (dovecot-configuration (mail-location &amp;quot;maildir:~/%n/Maildir&amp;quot;)))&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;By default both opensmtpd and dovecot use regular login username
authentication.  So my username and password that I login via email is the
same password that I use to login via ssh.  So my email config for
gnucode.me should look like this for gnus:&lt;/p&gt;&lt;pre&gt;&lt;code&gt;(nnimap &amp;quot;gnucode.me&amp;quot;
        (nnimap-stream ssl)
        (nnimap-address &amp;quot;imap.gnucode.me&amp;quot;)
        (nnimap-user &amp;quot;joshua&amp;quot;))&lt;/code&gt;&lt;/pre&gt;&lt;h2&gt;Some difficulties&lt;/h2&gt;&lt;ul&gt;&lt;li&gt;&lt;p&gt;I login via &amp;quot;joshua&amp;quot; and &amp;lt;password&amp;gt;.  I would prefer to login via joshua AT
gnucode.me.  That way I can distinguish joshua AT gnucode.me and joshua AT
propernaming.org&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;The above explanation strategy delivers all emails to /home/joshua/Maildir,
which essentially limits my total email accounts to one.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p&gt;The above has no spam filtering or email filtering.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;</summary></entry><entry><title>Hosting your Own Email Part 1</title><id>https://gnucode.me/hosting-your-own-email-part-1.html</id><author><name>Joshua Branson</name><email>jbranso@dismail.de</email></author><updated>2020-10-10T18:00:00Z</updated><link href="https://gnucode.me/hosting-your-own-email-part-1.html" rel="alternate" /><summary type="html">&lt;p&gt;I have wanted to host my own email for some time now.  I have not realized this
goal yet, but I am discovering that hosting your own email involves a fair
amount of different moving parts.  I have often heard from fairly technical
people that hosting your own email, is really complicated!  This post is an
explanation of what email is, and how guix system may be the best solution for
setting up email.  Please note that this is a multi-series blog post.  This is
part 1.&lt;/p&gt;&lt;p&gt;The &lt;a href=&quot;https://wiki.archlinux.org&quot;&gt;Archlinux wiki&lt;/a&gt; is perhaps the best wiki to
help you configure software.  The &lt;a href=&quot;https://wiki.archlinux.org/index.php/Mail_server&quot;&gt;Mail server wiki
page&lt;/a&gt; is a great place to
start learning about hosting your own email.  Let's start with the high level
view, as outlined by the archlinux guide.  Essentially hosting your own email
requires three bits of software:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;a mail transfer agent (MTA) receives and sends email  (opensmtpd)&lt;/li&gt;&lt;li&gt;a mail delivery agent (MDA), which gets the email from the MTA, and stores it
for a user.  (opensmtpd)&lt;/li&gt;&lt;li&gt;Remote users can access the emails via an MUA (mail user agent), via an IMAP
server. (dovecot)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;Since, guix has packaged an opensmtpd service already, I decided to use it, and
according to the arch wiki it looks like opensmtpd is an mail transfer agent and
a mail delivery agent!  So that's two of my issues sorted right there!  The last
set, which is letting remote users access the email, is handled by dovecot,
which is the IMAP email server.&lt;/p&gt;&lt;p&gt;By convention sending emails is done by &lt;code&gt;smtp.&amp;lt;yourdomainname&amp;gt;.com&lt;/code&gt;, and your
mail user agent (like Mozilla's Thunderbird), retrieves your email via
&lt;code&gt;imap.&amp;lt;yourdomainname&amp;gt;.com&lt;/code&gt;.  So I've decided get Let's Encrypt certificates
for my domain &amp;quot;gnucode.me&amp;quot; for the subdomains &lt;code&gt;smtp&lt;/code&gt; and &lt;code&gt;imap&lt;/code&gt;.  Like so:&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-scheme&quot;&gt;(use-service-modules certbot)

(define %nginx-deploy-hook
  (program-file
   &amp;quot;nginx-deploy-hook&amp;quot;
   #~(let ((pid (call-with-input-file &amp;quot;/var/run/nginx/pid&amp;quot; read)))
       (kill pid SIGHUP))))

(service certbot-service-type
         (certbot-configuration
          (email &amp;quot;jbranso@dismail.de&amp;quot;)
          (webroot &amp;quot;/srv/www&amp;quot;)
          (certificates
           (list
            (certificate-configuration
             (name &amp;quot;gnucode.me&amp;quot;)
             (domains '(&amp;quot;gnucode.me&amp;quot; &amp;quot;www.gnucode.me&amp;quot; &amp;quot;imap.gnucode.me&amp;quot;
             &amp;quot;smtp.gnucode.me&amp;quot; &amp;quot;mail.gnucode.me&amp;quot;))
             (deploy-hook %nginx-deploy-hook))))))&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The &lt;a href=&quot;https://wiki.archlinux.org/index.php/OpenSMTPD#Simple_OpenSMTPD/mbox_configuration&quot;&gt;Archlinux opensmtpd
page&lt;/a&gt;
has a great guide on setting up a simple mail server.  I've modified it to
deliver emails in the maildir format.&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-scheme&quot;&gt;(use-modules (guix gexp))

(define creds
  (plain-file &amp;quot;creds&amp;quot;
              &amp;quot;joshua $6$somelonghashofstrings&amp;quot;))

(define vdoms
  (plain-file
   &amp;quot;vdoms&amp;quot;
   &amp;quot;gnucode.me
gnu-hurd.com&amp;quot;))

(define vusers
  (plain-file
   &amp;quot;vusers&amp;quot;
   &amp;quot;joshua@gnucode.me  joshua
jbranso@gnucode.me     joshua&amp;quot;)

(service opensmtpd-service-type
         (opensmtpd-configuration
          (config-file
           (mixed-text-file &amp;quot;smtpd.conf&amp;quot;
                            &amp;quot;
# This is the smtpd server system-wide configuration file.
# See smtpd.conf(5) for more information.
# borrowed from the archlinux guix
# https://wiki.archlinux.org/index.php/OpenSMTPD#Simple_OpenSMTPD/mbox_configuration

# My TLS certificate and key
table aliases file:/etc/aliases
pki mail.gnucode.me cert \&amp;quot;/etc/letsencrypt/live/gnucode.me/fullchain.pem\&amp;quot;
pki mail.gnucode.me key \&amp;quot;/etc/letsencrypt/live/gnucode.me/privkey.pem\&amp;quot;

table creds \&amp;quot;&amp;quot; creds &amp;quot;\&amp;quot;
table vdoms \&amp;quot;&amp;quot; vdoms &amp;quot;\&amp;quot;
table vusers \&amp;quot;&amp;quot; vusers &amp;quot;\&amp;quot;

# listen on eth0, fairly explainatory
listen on eth0 tls pki mail.gnucode.me
listen on eth0 port 465 mails pki mail.gnucode.me auth &amp;lt;creds&amp;gt;
listen on eth0 port 587 tls-require pki mail.gnucode.me auth &amp;lt;creds&amp;gt;

action receive maildir virtual &amp;lt;vusers&amp;gt;
action send relay

match from any for domain &amp;lt;vdoms&amp;gt; action receive
match for any action send&amp;quot;))))&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;To serve your emails via imap, you also need a program to serve those files.
Dovecot is probably one of the better ones to use.  And it is conveniently
packaged in guix!&lt;/p&gt;&lt;pre&gt;&lt;code class=&quot;language-scheme&quot;&gt;(use-service-modules mail)
;; be default dovecot-service serves mail located in ~/Maildir, which is
;; what we have configured above.
(dovecot-service)&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Ideally the above would be enough to get you sorted, but it's not.  There are
three things you should do to make certain that your sent email is not flagged
as spam:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;proving you sent your email (DKIM)&lt;/li&gt;&lt;li&gt;Sender Policy Framework (SPF)&lt;/li&gt;&lt;li&gt;What should other email account do if your email fails the above two tests?
(DMARC)&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;I found &lt;a href=&quot;https://poolp.org/posts/2019-09-14/setting-up-a-mail-server-with-opensmtpd-dovecot-and-rspamd/&quot;&gt;this detailed email setup
guide&lt;/a&gt;
that I've found helpful.  Fair warning, it's like trying to drink water from a
fire hose.&lt;/p&gt;&lt;p&gt;The above configuration for opensmtpd is enough for me to receive emails for
joshua AT gnucode.me, but I am unable to send emails.  Also dovecot refuses to
authenticate my email client (gnus).  Fixes to those problems will appear in a
later post.&lt;/p&gt;</summary></entry></feed>